<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i> 表单</el-breadcrumb-item>
                <el-breadcrumb-item>新增用户</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="form-box">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="部门名称">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                

                <el-form-item  label="departmentId">
                    <el-input  v-model="form.departmentId"></el-input>
                </el-form-item>
                <el-form-item  label="departmentCode">
                    <el-input  v-model="form.departmentCode"></el-input>
                </el-form-item>
                <el-form-item  label="description">
                    <el-input  v-model="form.description"></el-input>
                </el-form-item>
                <el-form-item  label="createdBy">
                    <el-input  v-model="form.createdBy"></el-input>
                </el-form-item>
                <el-form-item  label="createdTime">
                    <el-input  v-model="form.createdTime"></el-input>
                </el-form-item>
                <el-form-item  label="lastUpdatedBy">
                    <el-input  v-model="form.lastUpdatedBy"></el-input>
                </el-form-item>
                <el-form-item  label="lastUpdatedTime">
                    <el-input  v-model="form.lastUpdatedTime"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">提交</el-button>
                    <el-button>取消</el-button>
                </el-form-item>
            </el-form>
        </div>

    </div>
</template>

<script>
    export default {
        data: function(){
            return {
                form: {           
                    name: '',
                    departmentId: '',
                    departmentCode: '',
                    description: '',
                    createdBy: '',
                    createdTime: '',
                    lastUpdatedBy: '',
                    lastUpdatedTime: ''
                },
                
            }
        },
        created(){
            this.getData();
        },
        methods: {
           handleCurrentChange(val){
                
                this.getData();
            },
	        getData(){
                 let self = this;
                 self.$axios.get('../department/getDepartment?departmentId=5a9407585f2ef92f015f2ef9e36d0000', {page:self.cur_page}).then((res) => {
                    self.form = res.data;   
                }) 
               
            },
	        onSubmit() {
		        var self = this;		       
		         if(!self.form.name){
		       		 this.$message.success('部门名称不可为空！');
		       		 return;
		        }
		        self.$axios({
		        method: 'post',
		        url: '../department/update',
		        handleAs:"json",
		        headers:{'Content-Type':'application/json'},
		        data: JSON.stringify(self.form)
		    }).then(function (res) {
		      self.sorcelist = res.data;		     
		     }).catch(function (err) {     
		     })
		      self.$message.success('修改成功！');
	    }
  	}
    }
</script>
